package com.oig.common.config;

import com.oig.common.filter.GlobalTraceIdFilter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;

@ConditionalOnWebApplication
@Configuration(proxyBeanMethods = false)
public class FilterAutoConfiguration {

    @Bean
    public FilterRegistrationBean<GlobalTraceIdFilter> traceIdFilterRegistrationBean() {
        FilterRegistrationBean<GlobalTraceIdFilter> registrationBean = new FilterRegistrationBean<>(new GlobalTraceIdFilter());
        registrationBean.setOrder(Ordered.HIGHEST_PRECEDENCE);
        return registrationBean;
    }

}
